<?php

$sql = "
select 	
	c.table_name		AS TABLE_NAME, 
	c.column_id			AS ORDINAL_POSITION,
	c.column_name		AS COLUMN_NAME,
	d.comments			AS COLUMN_COMMENT, 
	c.data_type			AS DATA_TYPE, 	
	''					AS COLUMN_TYPE,
	c.data_length		AS DATA_LENGTH, 
	c.data_precision	AS DATA_PREC,
	c.data_scale		AS DATA_SCALE,
    case 
        when c.nullable = 'Y' then 'NULL'
        else ''
    end as ISNULL, 
    ''					AS OPTIONS, 
	'N'					AS ISAUTO,
	c.data_default		AS COLUMN_DEFAULT,
	NVL(
        (SELECT 'PK' as pk 
        FROM USER_CONSTRAINTS A, USER_CONS_COLUMNS B 
        WHERE 
            A.CONSTRAINT_NAME = B.CONSTRAINT_NAME 
            AND A.TABLE_NAME = B.TABLE_NAME
            AND A.TABLE_NAME = C.TABLE_NAME
            AND A.CONSTRAINT_TYPE = 'P' AND B.COLUMN_NAME = C.COLUMN_NAME)	
	, '')				AS PK,
	''					AS UQ,
	''					AS C 
from 
    user_tab_columns c,
    user_col_comments d
where  
    c.column_name = d.column_name
    and c.table_name = d.table_name
    and c.table_name = '{$param['object']}'
order by c.column_id    
";

return $sql;

?>